home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / pc / dos / programg / decgif3 / showrgb.asm < prev    next >
Assembly Source File  |  1982-09-17  |  2KB  |  105 lines

  1. ;*******************************************************************************
  2. ;* Assembly Subroutines For DECGIF3.BAS 
  3. ;* By Rich Geldreich 1992
  4. ;* Assembled with TASM v2.00
  5. ;*
  6. ;* Routines to set an RGB palette for VGA/EGA.
  7. ;* 
  8. ;* 
  9. ;*
  10. .286
  11. Ideal
  12. Model Small
  13.  
  14. Public  ShowRGB
  15.  
  16. Codeseg
  17.  
  18. PalOffset       equ [ss:bp+12]
  19. PalSegment      equ [ss:bp+10]
  20. NumColors       equ [ss:bp+08]
  21. VGA             equ [word ss:bp+06]
  22.  
  23. Proc    ShowRGB
  24.         Push    bp                      ;Make stack frame.
  25.         Mov     bp, sp
  26.         Push    ds si di                ;Save regs
  27.         
  28.         Mov     si, PalOffset           ;ds:si addresses palette now.
  29.         Mov     ds, PalSegment
  30.         Mov     cx, NumColors           ;cx has number of colors in palette.
  31.         
  32.         Cmp     VGA, 0
  33.         Jz      @@EGA                   
  34.         
  35.         Mov     ax, cx                  ;*3
  36.         Shl     ax, 1
  37.         Add     cx, ax
  38.         
  39.         Mov     dx, 03C7h               
  40.         Xor     al, al
  41.         Out     dx, al
  42.         Inc     dx
  43.         Out     dx, al
  44.         Inc     dx
  45.         
  46.         Even
  47. @@PalLoop1:
  48.         Lodsb
  49.         Shr     al, 2
  50.         Out     dx, al
  51.         Loop    @@PalLoop1              ;Jump if more left.
  52.         
  53.         Pop     di si ds bp              
  54.         Retf    8        
  55.  
  56. @@EGA:
  57.         Mov     bl, ch
  58.  
  59. @@PalLoop2:
  60.         Xor     bh, bh
  61.         
  62.         ;**** Red
  63.         Lodsb                           ;Converts an 8-Bit RGB palette
  64.         Test    al, 128                 ;into something the BIOS can
  65.         Jz      @@10                    ;handle.
  66.         Or      bh, 4
  67. @@10:
  68.         Test    al, 64
  69.         Jz      @@20
  70.         Or      bh, 32
  71. @@20:
  72.  
  73.         ;**** Green
  74.         Lodsb
  75.         Test    al, 128
  76.         Jz      @@30
  77.         Or      bh, 2
  78. @@30:
  79.         Test    al, 64
  80.         Jz      @@40
  81.         Or      bh, 16
  82. @@40:
  83.  
  84.         ;**** Blue
  85.         Lodsb
  86.         Test    al, 128
  87.         Jz      @@50
  88.         Or      bh, 1
  89. @@50:
  90.         Test    al, 64
  91.         Jz      @@60
  92.         Or      bh, 8
  93. @@60:
  94.         Mov     ax, 01000h              ;Let BIOS do the dirty work this time.
  95.         Int     010h                    
  96.         
  97.         Inc     bl                      
  98.         
  99.         Loop    @@PalLoop2              ;Loop if more colors.
  100.         
  101.         Pop     di si ds bp             
  102.         Retf    8
  103. Endp    ShowRGB
  104. End
  105.